package com.dangdang.action.order;

import java.util.ArrayList;
import java.util.List;

import com.dangdang.action.BaseAction;
import com.dangdang.domain.Order;
import com.dangdang.domain.User;
import com.dangdang.service.OrderService;
import com.dangdang.service.ServiceFactory;
import com.dangdang.util.Constants;

/**
 * 客户订单控制层
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-2-3
 */
public class MyOrderAction extends BaseAction {

	/** 订单列表 */
	private List<Order> orderList;

	private OrderService orderService;

	public List<Order> getOrderList() {
		return orderList;
	}

	public void setOrderList(List<Order> orderList) {
		this.orderList = orderList;
	}

	/**
	 * 执行方法
	 * 
	 * @return
	 */
	public String execute() {
		orderList = new ArrayList<Order>();
		User user = (User) session.get(Constants.USER_KEY);
		orderService = ServiceFactory.getOrderService();
		orderList = orderService.findOrderByUserId(user.getId());
		return Constants.FORWARD_SUCCESS;
	}
}
